package com.wwf.filter;

import com.wwf.filter.com.wwf.util.TpCount;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;
@Activate(group = CommonConstants.CONSUMER)
public class TPMonitorFilter implements Filter{
    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        long beforeRequestTime = System.currentTimeMillis();
        Result result = invoker.invoke(invocation);
        long afterRequestTime = System.currentTimeMillis();
        long mit = afterRequestTime-beforeRequestTime;
       // System.out.println(mit);
        TpCount.doTpCount(mit,invocation.getMethodName());
        return result;
    }
}
